<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head id="Head1">
<title>客户管理</title>
<link href="../Styles/css.css" rel="stylesheet" type="text/css" />
<link href="../Styles/ts_css.css" rel="stylesheet" type="text/css" />
<script src="../Scripts/jquery.js" type="text/javascript"></script>
<script src="../Scripts/jquery.hotkeys.js" type="text/javascript"></script>
<script src="../Scripts/jstree/jquery.jstree.js" type="text/javascript"></script>
<script src="../Scripts/jquery.cookie.js" type="text/javascript"></script>
<script src="../Scripts/EmployeesManager.js" type="text/javascript"></script>

<!-- 导出 -->
<script>
    var tablesToExcel = (function() {
        var uri = 'data:application/vnd.ms-excel;base64,'
            , tmplWorkbookXML = '<?xml version="1.0"?><?mso-application progid="Excel.Sheet"?><Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">'
            + '<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office"><Author>Axel Richter</Author><Created>{created}</Created></DocumentProperties>'
            + '<Styles>'
            + '<Style ss:ID="Currency"><NumberFormat ss:Format="Currency"></NumberFormat></Style>'
            + '<Style ss:ID="Date"><NumberFormat ss:Format="Medium Date"></NumberFormat></Style>'
            + '</Styles>'
            + '{worksheets}</Workbook>'
            , tmplWorksheetXML = '<Worksheet ss:Name="{nameWS}"><Table>{rows}</Table></Worksheet>'
            , tmplCellXML = '<Cell{attributeStyleID}{attributeFormula}><Data ss:Type="{nameType}">{data}</Data></Cell>'
            , base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
            , format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
        return function(tables, wsnames, wbname, appname) {
            var ctx = "";
            var workbookXML = "";
            var worksheetsXML = "";
            var rowsXML = "";

            for (var i = 0; i < tables.length; i++) {
                if (!tables[i].nodeType) tables[i] = document.getElementById(tables[i]);

//              控制要导出的行数
                for (var j = 0; j < tables[i].rows.length; j++) {
                    rowsXML += '<Row>';

//                    控制导出的列数（在本例中，最后一列为button,导出的文件会出错，所以导出到倒数第二列
                    for (var k = 0; k < tables[i].rows[j].cells.length-1; k++) {
                        var dataType = tables[i].rows[j].cells[k].getAttribute("data-type");
                        var dataStyle = tables[i].rows[j].cells[k].getAttribute("data-style");
                        var dataValue = tables[i].rows[j].cells[k].getAttribute("data-value");
                        dataValue = (dataValue)?dataValue:tables[i].rows[j].cells[k].innerHTML;
                        var dataFormula = tables[i].rows[j].cells[k].getAttribute("data-formula");
                        dataFormula = (dataFormula)?dataFormula:(appname=='Calc' && dataType=='DateTime')?dataValue:null;
                        ctx = {  attributeStyleID: (dataStyle=='Currency' || dataStyle=='Date')?' ss:StyleID="'+dataStyle+'"':''
                            , nameType: (dataType=='Number' || dataType=='DateTime' || dataType=='Boolean' || dataType=='Error')?dataType:'String'
                            , data: (dataFormula)?'':dataValue
                            , attributeFormula: (dataFormula)?' ss:Formula="'+dataFormula+'"':''
                        };
                        rowsXML += format(tmplCellXML, ctx);
                    }
                    rowsXML += '</Row>'
                }
                ctx = {rows: rowsXML, nameWS: wsnames[i] || 'Sheet' + i};
                worksheetsXML += format(tmplWorksheetXML, ctx);
                rowsXML = "";
            }

            ctx = {created: (new Date()).getTime(), worksheets: worksheetsXML};
            workbookXML = format(tmplWorkbookXML, ctx);

//          查看后台的打印输出
            console.log(workbookXML);

            var link = document.createElement("A");
            link.href = uri + base64(workbookXML);
            link.download = wbname || 'Workbook.xls';
            link.target = '_blank';
            document.body.appendChild(link);
            link.click();
            document.body.removeChild(link);
        }
    })();
    </script>

<!--<script src="Scripts/EmployeesManager.js?0d189a86cc764626a482e60e084441dd" type="text/javascript"></script>-->
</head>
<body style="margin-top: 5px; background: #EFF3FF;">
		<script type="text/javascript">
		//<![CDATA[
		var theForm = document.forms['form1'];
		if (!theForm) {
			theForm = document.form1;
		}
		function __doPostBack(eventTarget, eventArgument) {
			if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
				theForm.__EVENTTARGET.value = eventTarget;
				theForm.__EVENTARGUMENT.value = eventArgument;
				theForm.submit();
			}
		}
		//]]>
		function openWin() {
			showModalDialog(
					"Wd_EmployeesUpdateManager.jsp",
					"example04",
					"dialogWidth:850px;dialogHeight:300px;dialogLeft:200px;dialogTop:150px;center: yes;help:yes;resizable:yes;status:yes")
		}
	</script>
	<script type="text/javascript">
     $(function () {  
        $.ajax({  
            type: "post", 
			dataType:"json",
            url: "/wanda/roompay/selectAllRoom.do",  
            success: function (data) {  
            	$('#roomName').empty();
				 $("#roomName").append("<option value=''>请选择</option>");
			         $.each(data.tasks,function(index,item){
			        	 alert("1");
				         $("#roomName").append( "<option value='"+item.roomId+"'>"+item.roomName+"</option>");
	            });
            }, 
        });  
     });  
 </script>
	<form action="/wanda/roompay/list.do" method="post">

		<div
			style="background: #EFF3FF; width: 22%; float: left; overflow-y: auto;">
			<!-- <div id="tree" class="tree" style="background: #EFF3FF;">
        </div> -->
		</div>
		<div style="width: 75%; float: left; border: 0px solid #82AFE8">
			<table width="100%">
				<tr>
					<td width="6%">客户姓名：</td>
					<td width="13%"><input name="customerName" type="text"
						id="customerName" style="width:95%;" /></td>
					<td width="7%">业务员姓名：</td>
					<td width="13%"><input name="name" type="text"
						id="name" style="width:95%;" /></td>
					<td width="6%">业务员编号：</td>
					<td width="13%"><input name="userId" type="text" id="userId"
						style="width:95%;" /></td>
					<td width="7%"></td>
					<td width="13%"><input type="submit" id="selectlike"
						class="submit" style="float: right" value="查询" /></td>
					<td width="7%">
				</tr>
			</table>
	</form>
	
	<table>
				<tr>
					<!-- <td width="5%">
					  <select class="select" id="roomName" name="roomName">  
                        <option value="">请选择</option>  
                       </select>  
                    </td>-->

					<!-- <td width="5%"><input type="button" id="btnAdd" class="button"
						style="float: right" value="房间退款" onclick="remoney()" /></td> -->
					
					<td width="5%"><input type="button" id="btnAdd" class="button"
						style="float: right" value="导出" onclick="tablesToExcel(['backViewTable'], ['ProductDay1'], 'Excel表.xls', 'Excel')" /></td>
					
				</tr>
    </table>
			
	<div class="cxlb_2" style="width: 100%">
		<table width="120%" class="tablist" id="backViewTable">
			<thead id="tablistHer">
				<tr>
					<th width="10%">合同编号</th>
					<th width="8%">客户姓名</th>
					<th width="8%">业务员编号</th>
					<th width="8%">业务员名称</th>
					<th width="8%">应收金额</th>
					<th width="8%">已收金额</th>
					<th width="8%">未收金额</th>
					<th width="8%">付款时间</th>
					<th width="8%">付款类型</th>
					<th width="8%">交纳次数</th>
					<th width="8%">待交纳次数</th>
					<th width="8%">状态</th>
				</tr>
			</thead>
			<tbody id="tab">

				<c:forEach items="${ plist }" var="slist">
					<c:if test="${slist.deleteState<1}">
						<tr>
							<td>${ slist.contractId }</td>
							<td>${ slist.customerName }</td>
							<td>${ slist.userId }</td>
							<td>${ slist.name }</td>
							<td>${ slist.receivableMoney }</td>
							<td>${ slist.receivedMoney }</td>
							<td>${ slist.uncollectedMoney }</td>
							<td><fmt:formatDate value="${ slist.payTime }"	pattern="yyyy-MM-dd"/></td>
							<td>${ slist.payType }</td>
							<td>${ slist.waitTimes }</td>
							<td>${ slist.deleteState }</td>
							<td><a href="/wanda/roompay/zuofei.do?roomPayId=${ slist.roomPayId }">作废</a>
							  ||<a href="/wanda/roompay/delete.do?roomPayId=${ slist.roomPayId }">删除</a>
						      ||<a href="/wanda/roompay/shoukuan.do?roomPayId=${ slist.roomPayId }">收款</a>
				 		      ||<a href="/wanda/roompay/returnMoney.do?roomPayId=${ slist.roomPayId }">退款</a>
						     </td>
						    </tr>
					</c:if>
				</c:forEach>
			</tbody>
		</table>

		<script type="text/javascript">
		<!--
			var Ptr = document.getElementById("tab").getElementsByTagName("tr");
			function pageLoad() {
				for (i = 1; i < Ptr.length + 1; i++) {
					Ptr[i - 1].className = (i % 2 > 0) ? "t1" : "t2";
				}
			}
			window.onload = pageLoad;
			for (var i = 0; i < Ptr.length; i++) {
				Ptr[i].onmouseover = function() {
					this.tmpClass = this.className;
					this.className = "t3";

				};
				Ptr[i].onmouseout = function() {
					this.className = this.tmpClass;
				};
			}
		//-->
		</script>

		<script>
			function remoney() {
				var roomId = document.getElementById("roomName").value;
					location.href = "/wanda/roompay/roomMoney.do?roomId="
							+ roomId ;
				
			}
		</script>
		
		<script>
			function daochu() {
					location.href = "/wanda/room_pay/contractTableExport.do";
							
				
			}
		</script>
		<!--添加  -->
		<script>
			//删除
			function add() {
				location.href = "/wanda/sale_chance/toadd.do";
			}
		</script>
		<div style="width: 100%;">

			<!-- AspNetPager 7.3.2  Copyright:2003-2010 Webdiyer (www.webdiyer.com) -->
			<div id="AspNetPager1" class="anpager"
				style="width:100%;text-align:left;">
				<div align="left" class="anpager" style="width:60%;float:left;">
					<a disabled="disabled" style="margin-right:10px;">首页</a><a
						disabled="disabled" style="margin-right:10px;">上一页</a><span
						class="cpb" style="margin-right:10px;">1</span><a
						disabled="disabled" style="margin-right:10px;">下一页</a><a
						disabled="disabled" style="margin-right:10px;">尾页</a>
				</div>
				<div class="anpager" style="width:40%;float:left;">
					记录总数：<font color="blue"><b>1</b></font> 总页数：<font color="blue"><b>1</b></font>
					当前页：<font color="red"><b>1</b></font>
				</div>
			</div>
			<!-- AspNetPager 7.3.2  Copyright:2003-2010 Webdiyer (www.webdiyer.com) -->


		</div>
	</div>

	</div>
	<input type="hidden" name="hidParentUuid" id="hidParentUuid" />
	<input type="hidden" name="hidUuid" id="hidUuid" />
	<input type="hidden" name="hidCookUuid" id="hidCookUuid" value="100002" />
	<input type="hidden" id="isShow" value="0" />
	<input name="hidpanelShow" type="hidden" id="hidpanelShow" />
	<input type="hidden" id="hidorganizationUuid" />
	<input type="hidden" id="hidfromSubmit" name="hidfromSubmit" value="1" />
	<input type="hidden" id="hidfromSubmit1" name="hidfromSubmit1" />
	<span id="lblScript"><script>
		$.cookie('jstree_open', '')
	</script></span>
	</form>
</body>
</html>
